//
//  GameViewController.h
//  IssuesGame
//
//  Created by Martin Grider on 10/2/09.
//  Copyright 2009 Regents of the University of Minnesota
//

#import <UIKit/UIKit.h>
#import "GameState.h"
#import "QuestionView.h"


@interface GameViewController : UIViewController {

	// game state and drawing related vars
	GameState *gameState;
	int tileSizeInPixels;
	int marginSizeInPixels;
	int gameBoardOffsetInPixels;
	BOOL respondToTouch;
	
	UIView	*gameBoardView;
	
	// game over (won) view
	UIImageView *gameOverWonImageView;
	BOOL gameOverWonViewIsDisplayed;

	// game over (lost) view
	UIImageView *gameOverLostImageView;
	BOOL gameOverLostViewIsDisplayed;
	
	// movement arrows
	UIButton *buttonLeft;
	UIButton *buttonRight;
	UIButton *buttonUp;
	UIButton *buttonDown;

	// game elements
	UIView *gameView;
	NSMutableArray *tileImages;
	UIImageView *starImageView;

	// for the popup/menu/help view(s)
	UIImageView *popupView;
	UIScrollView *scrollView;
	UIButton *bigButton;
	UIButton *littleButton;
	NSMutableArray *helpSubviews;

	// the QuestionView
	QuestionView *questionView;
	Tile *questionTile;
	BOOL questionViewIsDisplayed;
	BOOL questionAnsweredViewIsDisplayed;
	UIImageView *correctImageView;
	UIImageView *incorrectImageView;

	// touch detection
	CGPoint startTouchPosition;
	CGPoint currentTouchPosition;

}

@property (retain) GameState *gameState;
@property          int tileSizeInPixels;
@property          int marginSizeInPixels;
@property          int gameBoardOffsetInPixels;

@property (retain) UIImageView *gameOverWonImageView;
@property (retain) UIImageView *gameOverLostImageView;

@property (retain) UIButton *buttonLeft;
@property (retain) UIButton *buttonRight;
@property (retain) UIButton *buttonUp;
@property (retain) UIButton *buttonDown;

@property (retain) UIView *gameView;
@property (retain) NSMutableArray *tileImages;
@property (retain) UIImageView *starImageView;

@property (retain) UIImageView *popupView;
@property (retain) UIScrollView *scrollView;
@property (retain) UIButton *bigButton;
@property (retain) UIButton *littleButton;
@property (retain) NSMutableArray *helpSubviews;

@property (retain) QuestionView *questionView;
@property (retain) Tile *questionTile;
@property (retain) UIImageView *correctImageView;
@property (retain) UIImageView *incorrectImageView;

@property (nonatomic) CGPoint startTouchPosition;
@property (nonatomic) CGPoint currentTouchPosition;

// init methods
- (void)setupInitialGameState:(GameState *)gameStateObject;
- (void)drawFromGameStateWithOption:(BOOL)allTiles;
- (void)drawGameTileForX:(int)tileX forY:(int)tileY;
- (void)drawMovementArrowsAndFade;
- (void)drawGamePlayerImageFromGameState;
- (void)drawGameTilesFromGameState;
- (void)loadHelpSubViews;

// player motion methods
- (void)moveLeft;
- (void)moveRight;
- (void)moveUp;
- (void)moveDown;
- (void)animatePlayerMotion;
- (void) doMoveWithX: (int) xStep WithY: (int) yStep;

// player score methods
- (void)changePlayerScore:(int)modifier;
- (void)changePlayerScoreAnimationEnds;

// view switching methods
- (void)startNewGame;
- (void)handleCurrentPlayerLocation;
- (void)openCorrectAnswerView;
- (void)openIncorrectAnswerView;
- (void)closeQuestionView;
- (void)openPauseMenu;
- (void)closePauseMenu;
- (void)openGameOverLost;
- (void)closeGameOverLost;
- (void)openGameOverWon;
- (void)closeGameOverWon;
- (void)openHelpMenu;
- (void)closeHelpMenu;
- (void)openInitialMenu;
- (void)closeInitialMenu;

// memory methods
- (void)releaseGameTileImages;

@end
